import requests


class EmpApi:

    # 添加员工
    @classmethod
    def add_emp_api(cls, token, body):
        url = "http://ihrm2-test.itheima.net/api/sys/user"
        headers = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.post(url=url, headers=headers, json=body)
        return resp

    # 修改员工
    @classmethod
    def change_emp_api(cls, token, emp_id, body):
        url = f"http://ihrm2-test.itheima.net/api/sys/user/{emp_id}"
        headers = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.put(url=url, headers=headers, json=body)
        return resp

    # 查询员工
    @classmethod
    def query_emp_api(cls, token, emp_id):
        url = f"http://ihrm2-test.itheima.net/api/sys/user/{emp_id}"
        headers = {"Authorization": token}
        resp = requests.get(url=url, headers=headers)
        return resp

    # 删除员工
    @classmethod
    def del_emp_api(cls, token, emp_id):
        url = f"http://ihrm2-test.itheima.net/api/sys/user/{emp_id}"
        headers = {"Authorization": token}
        resp = requests.delete(url=url, headers=headers)
        return resp
